from django.contrib import admin
from register.models import UserInfo, Product_List, Product_Details, Image_Space, Product_Comment, Professional_skill, \
    Introduce_Myself


admin.site.site_header = '后台管理系统'
admin.site.index_title = '首页'
from django.contrib.auth.models import Group, User

admin.site.unregister(Group)
admin.site.unregister(User)


# admin.site.register(UserInfo)
# 商品列表
@admin.register(Product_List)
class Product_ListAdmin(admin.ModelAdmin):
    list_display = ('Pname', 'Pauthor', 'Phref')
    list_filter = ['Pauthor']  # 过滤器
    search_fields = ['Pname']
    list_display_links = ['Pname']  # 修改关键字
    # radio_fields = {'person':admin.HORIZONTAL}
    list_per_page = 20



# 商品详情
@admin.register(Product_Details)
class Product_DetailsAdmin(admin.ModelAdmin):
    list_display = ('Product_name', 'Item', 'FOB_Price', 'Port', 'Minimum_Order_Quantity', 'Supply_Ability',
                    'Payment_Terms', 'Brand_Name', 'Product_List_id')
    search_fields = ['Product_name']
    list_display_links = ['Product_name']  # 修改关键字
    list_per_page = 20


# 商品图片
@admin.register(Image_Space)
class Image_SpaceAdmin(admin.ModelAdmin):
    list_display = ('Image_name', 'Product_List_ids', 'Image_loves', 'Image_downloads', 'Image_comments', 'Image_href')
    # search_fields = ['Image_name']
    list_filter = ['Product_List_ids']
    list_display_links = ['Image_name']  # 修改关键字
    list_per_page = 20


# 产品评论
@admin.register(Product_Comment)
class Product_CommentAdmin(admin.ModelAdmin):
    list_display = ('Commentator', 'Commentator_Tele', 'Commentator_Mailbox', 'Commentator_comment',
                    'Commentator_datetime', 'Product_id')
    search_fields = ['Commentator']
    list_display_links = ['Commentator']  # 修改关键字
    list_per_page = 20


# 自我介绍
@admin.register(Introduce_Myself)
class Introduce_MyselfAdmin(admin.ModelAdmin):
    list_display = ('Name', 'Age', 'Gender', 'Address', 'University', 'Major', 'Mastery_Degree', 'Telephone',
                    'Mailbox')
    search_fields = ['Name']
    list_display_links = ['Name']  # 修改关键字
    list_per_page = 20


# 专业技能
@admin.register(Professional_skill)
class Professional_skillAdmin(admin.ModelAdmin):
    list_display = ('id', 'Introduce_Myself_ids', 'Professional_Introduction')
    search_fields = ['Professional_Introduction']
    list_display_links = ['Introduce_Myself_ids']  # 修改关键字
    list_per_page = 20
